﻿<#assign classNameLower = className?uncap_first>
<%@ page contentType="text/html; charset=gb2312"%>
<%@ page import="com.shareinfo.smbase"%>
<%@ page import="com.shareinfo.dbc.TResultSet"%>
<%@ page import="com.shareinfo.TGlobal"%>
<%@ page import="${packageName}.${className}ManageOper"%>
<%
	response.setHeader("Pragma", "No-cache");
	response.setHeader("Cache-Control", "no-cache");
	response.setDateHeader("Expires", 0);

	request.setCharacterEncoding("gb2312");
%>
<html>
	<head>
		<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
		<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
		<META HTTP-EQUIV="Expires" CONTENT="0">
		<link rel="stylesheet" type="text/css" href="../include/style.css">
		<title>${comments}</title>
		<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
	</head>
	<jsp:useBean id="beanOper" scope="session" class="com.shareinfo.TOperator" />
	<jsp:useBean id="${classNameLower}Bean" scope="request" class="${packageName}.${className}Bean">
		<jsp:setProperty name="${classNameLower}Bean" property="*"/>
	</jsp:useBean>
	<script language="JavaScript">
		//列表上的删除连接使用的事件函数
		function btnOnDelete(id)
		{
			var msg = "\n 请确认是否继续删除【" + id + "】"
		  			+ "\n\n 确认删除请选择 “确定”";
			if(confirm(msg))  //如果点击“确定”，则给两个变量赋值，然后提交页面
 			{
   				document.frmOk.id.value = id;
   				document.frmOk.pageAction.value = "3";
   				document.frmOk.pageSubmit.value = "1";
   				document.frmOk.submit();
 			}
		  	return false;
		}
	</script>
	<%
		//如果用户没有登录，则跳转到登录页面
		if (!beanOper.isLogin){
			out.println("<script language=\"JavaScript\">");
			out.println("	window.parent.location = \"../index.jsp?logout=1\"");
			out.println("</script>");
		}
		//添加产品管权限判断
		boolean hasRightA = beanOper.HasRight("B7A");
		boolean hasRightB = beanOper.HasRight("B7B");
		boolean hasRightC = beanOper.HasRight("B7C");
		//没有浏览权限，则回退
		if (!hasRightA){
			out.println("<script language=\"JavaScript\">");
			out.println("	alert('您没有浏览${comments}权限不能浏览！'); window.history.go(-1); ");
			out.println("</script>");
		}
		
		String pageAction = smbase.BlankNull(request.getParameter("pageAction"));
		String pageSubmit = smbase.BlankNull(request.getParameter("pageSubmit"));
		${className}ManageOper ${classNameLower}ManageOper = new ${className}ManageOper(beanOper);
		//删除
		if("3".equals(pageAction) && "1".equals(pageSubmit))
		{
			<#if table.keyJavaType="java.util.HashMap">
				java.util.HashMap id=new java.util.HashMap();
				<#list table.keyColumns as column>
					id.put("${column.classColumnName}", smbase.BlankNull(request.getParameter("${column.classColumnName}")));
				</#list>
			<#else>
				<#list table.keyColumns as column>
					${table.keyJavaType} id=smbase.BlankNull(request.getParameter("${column.classColumnName}"));
				</#list>
			</#if>
			int ret = ${classNameLower}ManageOper.delete${className}ById(id);
			out.println("<script language='javascript'>");
			if(ret >= 0){				
				out.println("alert('操作成功！')");
			}else{
				out.println("alert('操作失败！')");				
			}
			out.println("</script>");
		}
		
		//////////////////////////////////////////////////////
		String vpageurl = "${classNameLower}.jsp";
		String tmpcp = smbase.BlankNull(request.getParameter("currpage"), "1");
		int currpage = Integer.parseInt(tmpcp); //当前页
		if (currpage <= 0){
			currpage = 1;
		}
		int vrpp = 30; //每页显示的记录数
		int vfrom = (currpage - 1) * vrpp + 1; //当前页对应的记录位置
		TResultSet rs = ${classNameLower}ManageOper.query${className}(${classNameLower}Bean, vfrom, vrpp);
		int vcount = 0; //记录总数
		if (rs != null){
			vcount = rs.MaxCount;
		}
		String gopagestr = TGlobal.g_dbcon.getGoPageStr(vpageurl, vcount, currpage, vrpp);
	%>
	<body background="../images/right_bg.gif">
		<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
			<tr>
				<td valign="top">					
					<table width="100%" border="0" align="center" cellpadding="2" cellspacing="0">
						<tr>
							<td width="62%" height="26" valign="bottom" background="../images/main_bg_top1.jpg">
								<div align="left">
									<table width="300" height="20" border="0" cellpadding="0" cellspacing="0">
										<tr>
											<td width="3%">
												&nbsp;
											</td>
											<td width="97%" valign="bottom" class="newstitle">
												<font color="#FFFFFF"><strong>${comments}信息列表</strong>
												</font>
											</td>
										</tr>
									</table>
								</div>
							</td>
							<td width="38%" valign="bottom" background="../images/main_bg_top11.jpg">
								<img src="../images/refresh.gif" width="13" height="16" alt="刷新当前页面" onClick="javascript:location.reload()">
								<img src="../images/help.gif" width="13" height="16" alt="获得操作帮助" onClick="return ShowHelp('14')">
							</td>
						</tr>
					</table>
					<form action="" method="post" name="frmOk">
					<input type="hidden" name="pageSubmit" id="pageSubmit" value="0">
					<input type="hidden" name="pageAction" id="pageAction" value="0">
					<table width="100%" border="0" align="center" cellspacing="0">						
						<tr>
							<td height="24" colspan="3">
								<table width="100%" border="0" align="center" cellspacing="1" bgcolor="#B4B2B5">
									<tr bgcolor="#EFF8FF">
										<td height="18" bgcolor="#EFF8FF">
											<img src="../images/dot1.gif" width="12" height="8">											
											<%if (hasRightB) {%>												
												<a href="${classNameLower}Info.jsp?pageAction=1" target="_self">添加${comments}</a>												
											<%} %>
										</td>
									</tr>
								</table>
							</td>
						</tr>
						<tr>
							<td height="24" colspan="3">
								<table width="100%" border="0" align="center" cellspacing="0" bgcolor="#FFFFFF">
									<tr>
										<td style="width:100%;height:18px;text-align:left">
											<#list table.columns as column>
												${column.sqlRemarks}：<input type="text" name="${column.classColumnName}" value="<%=${classNameLower}Bean.get${column.classColumnName?cap_first}()%>">
											</#list>
											<input type="submit" name="qryBtn" id="qryBtn" value=" 查询 " onclick="return btnOnOk();">
										</td>
									</tr>
								</table>
							</td>
						</tr>
						<tr>
							<td height="20">
								<table width="100%" border="0" align="center" cellspacing="1" bgcolor="#999999">
									<tr>
										<td height="19" bgcolor="#EFF8FF">
											<div align="right">
												<%=gopagestr%>
											</div>
										</td>
									</tr>
								</table>
							</td>
						</tr>
						<tr>
							<td height="40" valign="top">
								<div align="center">
									<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#F7FBFF"  class="queryListTable">
										<tr class="headRow">
											<#list table.columns as column>
												<td>${column.sqlRemarks}</td>
											</#list>
											<td>操作</td>
										</tr>
										<%
											try {
												int rowCount = 0;
												while (rs != null && rs.next()) {
										%>
										<tr bgcolor="<%=((rowCount++ % 2) == 0)?"#EEEEEE":"#FFFFFF"%>">
											<#list table.columns as column>
											<td style="text-align:center">												
												<%=rs.getString("${column.sqlColumnName}")%>
											</td>
											</#list>
											<td style="text-align:center">
											<%if (hasRightB && ("0".equals(beanOper.MyRoleid))) {%>
												<a href="./${classNameLower}Info.jsp?pageAction=2&id=" title="修改">修改</a>
												<a href="#" onclick="return btnOnDelete('id');"  title="删除">删除</a>
											<%}%>
											</td>
										</tr>
										<%
											}
										} catch (Exception e) {
											e.printStackTrace();
										} finally {
											if (rs != null) {
												rs.close();													
											}
											rs = null;
										}
										%>
									</table>
								</div>
							</td>
						</tr>
						<tr>
							<td height="20">
								<table width="100%" border="0" align="center" cellspacing="1" bgcolor="#999999">
									<tr>
										<td height="19" bgcolor="#EFF8FF">
											<div align="right">
												<%=gopagestr%>
											</div>
										</td>
									</tr>
								</table>
							</td>
						</tr>					
					</table>
					</form>
				</td>
			</tr>
			<tr>
				<td valign="bottom">
					<table width="100%" border="0" cellpadding="0" cellspacing="0">
						<tr>
							<td background="../images/main_bg_b.jpg">
								&nbsp;
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
	</body>
</html>
